package prototypePattern;

import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.RandomUtil;

/**
 * @Author: 582895699@qq.com
 * @Desctription: 原型模式
 * @Date: Created in 2021/12/15 9:55
 */
public class Client {

    public static int max_value = 5;

    public static void main(String[] args) {
        int i = 0;
        Mail mail = new Mail(new AdvTemplate());
        mail.setTail("版权所用");


        while (i < max_value) {
            mail.setApplication(RandomUtil.randomString(4) + "先生（女士）");
            mail.setReceiver(RandomUtil.randomInt(10000, 90000) + "@qq.com");
            sendMail(mail);
            i++;
        }
    }

    public static void sendMail(Mail mail) {
        Thread thread = Thread.currentThread();
        System.out.println(StrFormatter.format("标题：[{}] " + " 收件人:[{}] " + "发送成功; thread:[{}]", mail.getSubject(), mail.getReceiver(), thread.getName()));

    }
}
